package com.wanmait.translate.configuration.interceptor;

import com.wanmait.translate.pojo.SystemUser;
import com.wanmait.translate.utils.CommonMessage;
import org.springframework.web.servlet.HandlerInterceptor;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

/*
 * @Author huweibin
 * @Description 全局拦截器，
 * @Date 10:27 2020/10/30
 **/
public class MvcInterceptor implements HandlerInterceptor {

    //preHandle是请求执行前执行的,返回true的时候才会执行
    @Override
    public boolean preHandle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object o) throws Exception {
        //沒有加shiro时模拟登陆
        HttpSession session = httpServletRequest.getSession();
        SystemUser systemUser = new SystemUser();
        systemUser.setId(1);
        session.setAttribute(CommonMessage.USER,systemUser);
        return true;
    }

}
